/*
 * TaskStatusDelegate.cpp
 *
 *  Created on: 18.10.2010
 *      Author: OnGuard
 */

#include "TaskStatusDelegate.h"

TaskStatusDelegate::TaskStatusDelegate(QWidget *parent) :
	QItemDelegate(parent) {

	statusesIcons.insert(1, QStyle::SP_DialogCloseButton);
	statusesIcons.insert(0, QStyle::SP_TitleBarContextHelpButton);
	statusesIcons.insert(-1, QStyle::SP_CustomBase);
}

TaskStatusDelegate::~TaskStatusDelegate() {
}

void TaskStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
	quint32 statusId = index.data().toUInt();

	//QApplication::style()->drawItemPixmap(painter, option.rect, Qt::AlignCenter, QApplication::style()->standardPixmap(QStyle::StandardPixmap(index.row())));

	if (index.data(Qt::BackgroundColorRole).isValid()) {
		painter->fillRect(option.rect, index.data(Qt::BackgroundColorRole).value<QColor> ());
	}
	QApplication::style()->drawItemPixmap(painter, option.rect, Qt::AlignCenter, QApplication::style()->standardPixmap(statusesIcons.value(
			statusId, QStyle::SP_ArrowLeft)));

}
